//
//  HJBirthdayVC.m
//  project
//
//  Created by jc on 2019/5/8.
//  Copyright © 2019 健健. All rights reserved.
//

#import "HJBirthdayVC.h"
#import "HJDataPikerView.h"

@interface HJBirthdayVC ()
@property (weak, nonatomic) IBOutlet UIView *bgView;
@property (weak, nonatomic) IBOutlet UILabel *brithdayLabel;
@property (weak, nonatomic) IBOutlet UIButton *brithdayBtn;
@property (nonatomic,strong) NSString *birthday;
@property (weak, nonatomic) IBOutlet UIButton *commitBtn;
@end

@implementation HJBirthdayVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.navTitle = @"修改生日";
    self.brithdayLabel.text = [HJUserManager getUserModel].birthday;
    NSLog(@"%@",[HJUserManager getUserModel].userId);
    
    [self.view setupShadowWithView:self.bgView];
    [self.view setupShadowWithView:self.commitBtn];
    @weakify(self)
    [[self.brithdayBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
        @strongify(self)
        LKLog(@"时间选择器");
        HJDataPikerView * picker = [HJDataPikerView initDatePicker];
        [picker show];
        picker.completeDatePickerBlock = ^(NSString * _Nonnull year, NSString * _Nonnull month, NSString * _Nonnull day, NSString * _Nonnull date) {
            self.brithdayLabel.text = date;
            self.birthday =[NSString stringWithFormat:@"%@-%@-%@",year,month,day];
        };
    }];
    
    [[self.commitBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
        @strongify(self)
        if (self.birthday.length==0) {
            [self showErrorHUDWithError:@"请选择日期"];
            return ;
        }
        
        [HJUserManager updateUserModelWithParams:@{@"birthday":self.birthday} success:^{
            [self.navigationController popViewControllerAnimated:YES];
        }];
    }];
    
}


@end
